<template>
  <div class="home">
    <van-search
      v-model="searchVal"
      shape="round"
      placeholder="请输入搜索关键词"
      disabled
      @click="handleSearch"
    />
    <!-- 轮播 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="blue">
      <van-swipe-item v-for="item in banner" :key="item.id">
        <img :src="item.image_url" width="100%" alt="" />
      </van-swipe-item>
    </van-swipe>

    <transition name="van-fade">
      <div class="proup-shadow" v-show="$store.state.isShadow"></div>
    </transition>

    <transition name="van-slide-right">
      <router-view />
    </transition>
  </div>
</template>

<script>
// @ is an alias to /src
// import HelloWorld from '@/components/HelloWorld.vue'
// import axios from "axios";
// import request from "@/request/request";
import { getHomeList } from "@/request/api";

export default {
  name: "Home",
  components: {},
  data() {
    return {
      searchVal: "",
      banner: []
    };
  },
  methods: {
    handleSearch() {
      this.$router.push("/home/searchPopup");
      this.$store.commit("ChangeisShadow", true);
    }
  },
  created() {
    getHomeList()
      .then(res => {
        // console.log("successopopopopopopoopopo");
        // console.log(res.data.banner);
        this.banner = res.data.banner;
      })
      .catch(err => {
        console.log(err);
      });
  }
};
</script>

<style lang="less">
.proup-shadow {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 98;
}

// .slide-enter {
//   //过渡开始之前的样式写在这里
//   right: -100%;
// }

// .slide-enter-active {
//   //过渡属性写在这里
//   transition: all 0.3s;
// }
// .slide-enter-to {
//   //过渡结束之后的样式写在这里
//   right: 0;
// }

// .slide-leave {
//   //过渡开始之前的样式写在这里
//   right: 0;
// }

// .slide-leave-active {
//   //过渡属性写在这里
//   transition: all 0.3s;
// }
// .slide-leave-to {
//   //过渡结束之后的样式写在这里
//   right: -100%;
// }
</style>